import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  Index,
} from "typeorm";
import { ApiProperty } from "@nestjs/swagger"; // 引入 Swagger 注解

@Entity("coupon_info",{database:'daijia_coupon'}) // 指定表名
export class CouponInfo {
  @ApiProperty({ description: "主键id", example: 1 })
  @PrimaryGeneratedColumn({ type: "bigint", comment: "主键id" })
  id: number;

  @ApiProperty({
    description: "优惠券类型：1-满减券，2-折扣券",
    example: 1,
    enum: [1, 2],
  })
  @Column({ type: "tinyint", nullable: false, default: 1, comment: "优惠券类型：1-满减券，2-折扣券" })
  coupon_type: number;

  @ApiProperty({ description: "优惠券名称", example: "满100减10", maxLength: 100, required: false })
  @Column({ length: 100, nullable: true, comment: "优惠券名称" })
  name: string;

  @ApiProperty({ description: "优惠金额", example: 10.0, minimum: 0 })
  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false, default: 0.0, comment: "优惠金额" })
  amount: number;

  @ApiProperty({ description: "折扣率", example: 0.9, minimum: 0, maximum: 1, required: false })
  @Column({ type: "decimal", precision: 10, scale: 2, nullable: true, comment: "折扣率" })
  discount: number;

  @ApiProperty({ description: "使用条件金额", example: 100.0, minimum: 0 })
  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false, default: 0.0, comment: "使用条件金额" })
  condition_amount: number;

  @ApiProperty({ description: "发布数量", example: 1000, minimum: 0 })
  @Column({ type: "int", nullable: false, default: 1, comment: "发布数量" })
  publish_count: number;

  @ApiProperty({ description: "每人限领数量", example: 1, minimum: 0 })
  @Column({ type: "int", nullable: false, default: 1, comment: "每人限领数量" })
  per_limit: number;

  @ApiProperty({ description: "已使用数量", example: 500, minimum: 0 })
  @Column({ type: "int", nullable: false, default: 0, comment: "已使用数量" })
  use_count: number;

  @ApiProperty({ description: "已领取数量", example: 800, minimum: 0 })
  @Column({ type: "int", nullable: false, default: 0, comment: "已领取数量" })
  receive_count: number;

  @ApiProperty({ description: "过期时间", example: "2023-12-31T23:59:59Z", required: false })
  @Column({ type: "datetime", nullable: true, comment: "过期时间" })
  expire_time: Date;

  @ApiProperty({ description: "优惠券描述", example: "满100减10优惠券", maxLength: 255, required: false })
  @Column({ length: 255, nullable: true, comment: "优惠券描述" })
  description: string;

  @ApiProperty({ description: "状态：1-启用，0-禁用", example: 1, enum: [0, 1], required: false })
  @Column({ type: "tinyint", nullable: true, comment: "状态：1-启用，0-禁用" })
  status: number;

  @ApiProperty({ description: "创建时间", example: "2023-01-01T00:00:00Z", readOnly: true })
  @CreateDateColumn({
    type: "timestamp",
    comment: "创建时间",
  })
  create_time: Date;

  @ApiProperty({ description: "更新时间", example: "2023-01-01T00:00:00Z", readOnly: true })
  @UpdateDateColumn({
    type: "timestamp",
    comment: "更新时间",
  })
  update_time: Date;

  @ApiProperty({ description: "逻辑删除标识：0-未删除，1-已删除", example: 0, enum: [0, 1] })
  @Column({
    type: "tinyint",
    nullable: false,
    default: 0,
    comment: "逻辑删除标识：0-未删除，1-已删除",
  })
  is_deleted: number;
}